<?php
require_once '../include/common.inc.php';

function get_onlineip() {    $ch = curl_init('http://www.ip138.com/ip2city.asp');    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    $a  = curl_exec($ch);    preg_match('/\[(.*)\]/', $a, $ip);    return $ip[1]; }

$ip = get_onlineip();

$query="select * from serverinfo order by id desc limit 1";

$result=$db->get_one($query);

$sip = $result[ip];
$sport = $result[port];

if (!empty($type) && $type == 1)
{
	echo $sip; 
	echo ":"; 
	echo $sport;
}
else
{
	if ($ip != $sip || $port != $sport)
	{
	$query = "INSERT INTO serverinfo SET ip = '$ip',port = '$port'";
	$db->query($query);
	}
	echo $ip; 
	echo ":"; 
	echo $port;
}
?>